package com.emep.changzhi.analyse.http.Technology;

import com.emep.changzhi.analyse.entity.Technology.SCRDenitrification;
import com.emep.changzhi.analyse.entity.Technology.SemiDryDesulfurization;
import com.emep.changzhi.analyse.model.ResultBean;
import com.emep.changzhi.analyse.service.Technology.SCRDenitrificationService;
import com.emep.changzhi.analyse.service.Technology.SemiDryDesulfurizationService;
import com.emep.changzhi.analyse.utils.Constant;
import com.emep.changzhi.analyse.utils.DataValidator;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * SCR脱销
 */
@RestController
@RequestMapping("scr")
@Api(value="SCR脱销",tags={"SCR脱销操作接口"})
public class SCRDenitrificationController {
    @Autowired
    private SCRDenitrificationService sCRDenitrificationService;

    @ApiOperation(value="添加", notes="添加")
    @ApiResponses({ @ApiResponse(code = 1, message = "操作成功"),
            @ApiResponse(code = 0, message = "操作失败，服务器内部异常"),
            @ApiResponse(code = 303, message = "权限不足") })

    @PostMapping(value = "add")
    public ResultBean<SCRDenitrification> add(@RequestParam Map<String, Object> payload){
        ResultBean result = DataValidator.validateMapData(payload);
        if (result.getCode() == Constant.RESULT_CODE_SUCCESS){
            return result.boolAdd(sCRDenitrificationService.add(payload)) ;
        }
        return  result;

    }

    @ApiOperation(value="查询", notes="查询")
    @ApiResponses({ @ApiResponse(code = 1, message = "操作成功"),
            @ApiResponse(code = 0, message = "操作失败，服务器内部异常"),
            @ApiResponse(code = 303, message = "权限不足") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "starTime", value = "起始时间", required = true, dataType = "String",paramType="query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = true, dataType = "String",paramType="query")
    })
    @GetMapping(value = "list")
    public ResultBean<SCRDenitrification> list(@RequestParam String page, @RequestParam String rows, @RequestParam Map<String, Object> payload){
        ResultBean result = DataValidator.validateMapData(payload,"starTime","endTime");
        if (result.getCode() == Constant.RESULT_CODE_SUCCESS){
            return result.boolAdd(sCRDenitrificationService.list(Integer.valueOf(page),Integer.valueOf(rows),payload)) ;
        }
        return  result;

    }
}
